package com.csw.compose.ui.module.component.container

import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedCard
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.csw.compose.theme.pagePadding
import com.csw.compose.ui.Destination
import com.csw.compose.ui.components.BodyText
import com.csw.compose.ui.components.LabelText
import com.csw.compose.ui.components.NormalSpacer
import com.csw.compose.ui.components.OlItem
import com.csw.compose.ui.components.PrimaryTitle
import com.csw.compose.ui.components.UlItem
import com.csw.compose.ui.module.BasePage

@Preview
@Composable
fun CardPagePreview() {
    BasePage({}, "卡片（Card）") {
        CardPage()
    }
}

class CardPageData {
    companion object : Destination("CardPage")
}

/**
 *[参考](https://developer.android.google.cn/develop/ui/compose/components/card?hl=zh-cn)
 */
@Composable
fun CardPage() {
    Column(
        modifier = Modifier
            .padding(horizontal = pagePadding)
            .verticalScroll(rememberScrollState())
    ) {
        PrimaryTitle("简介")
        BodyText("卡片，与CardView作用相同，常作为容器用于实现圆角卡片效果")
        NormalSpacer()
        Card(
            colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.primary),
            elevation = CardDefaults.cardElevation(defaultElevation = 20.dp),
            border = BorderStroke(1.dp, Color.Yellow)
        ) {
            Box(Modifier.padding(10.dp)) {
                Text("Filled")
            }
        }
        NormalSpacer()
        UlItem("Card")
        LabelText("填充类型卡片")
        NormalSpacer()
        OlItem(1, "colors")
        LabelText("颜色定义，可以指定卡片背景色与内容颜色，还可指定组件禁用状态的颜色")
        NormalSpacer()
        OlItem(2, "elevation")
        LabelText("海拔高度，可以指定默认、按压、焦点、拖拽、禁用等不同状态下的卡片海拔高度")
        NormalSpacer()
        OlItem(3, "border")
        LabelText("边框")
        NormalSpacer()

        OutlinedCard(
            elevation = CardDefaults.cardElevation(defaultElevation = 20.dp),
            border = BorderStroke(1.dp, Color.Yellow)
        ) {
            Box(Modifier.padding(10.dp)) {
                Text("Outlined")
            }
        }
        NormalSpacer()
        UlItem("OutlinedCard")
        LabelText("轮廓卡片")
        NormalSpacer()
    }
}